<?php
$CI =& get_instance();
//$CI->load->library('pagination');
$CI->load->model("Model_mediaset", "model_mediaset");
$CI->load->model('Model_media', 'model_media');

$t1 = $content['t1'];
$t1 = unserialize($t1);
$media_thumb = $CI->config->item("media_thumb");

/*$total = $CI->model_media->find_by_group_count($t1['group']);
$offset = 0;
$per_page = $this->uri->segment(4,0);
if($per_page < $total){
	$offset = $per_page;
}*/
$limit = $t1['quantity'];

$mediaset = $CI->model_mediaset->find_by_ids($t1['group']);
$ids = null;
foreach($mediaset as $item){
	$ids .= $item['media_ids'] . ",";
}
$ids = explode(",",$ids);
$list_media = $CI->model_media->find_by_ids($ids);

/*$config['base_url'] = site_url(array('c'=>'home', 'm'=>'index', 'nav'=>$node['id']));
$config['uri_segment'] = 4;
$config['total_rows'] = $total;
$config['per_page'] = $limit;
$CI->pagination->initialize($config);*/
?>
<div class="left-2-col texture">
</div>
<div class="col_center">
	<h2><?= $content['name'];?></h2>
	<div class="gallery-cont">
		<h4><b><?=$this->lang->line('Gallery');?></b></h4>
		<?php if(!empty($list_media)):?>
		<?php
			$count_list = count($list_media);
			$height = "min-height:110px;";
		    if($count_list >= 5) $height = "min-height:210px;";
		    if($count_list >= 10) $height = "min-height:305px;";
		    $class = "disabled";
		    if($count_list>15) $class = "";
     	?>
		<div class="navi"></div>
		<div class="scrollable" style="<?=$height?>">
			<div class="gallery-grid">
				<?php $k = 0; foreach($list_media as $item):?>
				<?php if($k==0 || ($k % 15 == 0)):?>
				<div class="media-group">
				<?php endif;?>
					<div class="item">
						<a class="customGal" href="<?=$media_thumb['user_media_url'].$item['rawname'].$item["fileext"]?>" title="<?=$item['content']?>" style="width: 120px">
							<img src="<?=$media_thumb['user_media_url'].$item['rawname'].$media_thumb['thumb_marker'].$item["fileext"]?>" alt="<?=$item['title']?>" width="120px"/>
							<span class="gallery-bg"></span>
							<span class="gallery-border"></span>
						</a>
					</div>
					<?php if(($k > 1) && ($k % 5 == 4)):?>
					<div class="clearfix"></div>
					<?php endif;?>
				<?php if((($k != 0) && ($k % 15 == 14)) || ($k+1==count($list_media))):?>
				</div>
				<?php endif;?>
				<?php $k++;endforeach; ?>
			</div>
			<div class="clearfix"></div>
		</div>
		<div style="margin: 0 300px;">
			<a class="prevPage browse left"></a>
			<a class="nextPage browse right <?=$class?>"></a>
		</div>
		<?php endif;?>
	</div>
</div>
<div class="clearfix"></div>